home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_DBF.TXT < prev    next >
Encoding:
Text File  |  1992-12-22  |  9.2 KB  |  225 lines

  1. '
  2. 'Class description:
  3. '
  4. !short:Dbf Class structure:
  5. Class Dbf:
  6. ~~~~~~~~~~
  7. With help of the class OneDbf this class manipulates with all database files
  8. at time. Each required command is precessed on all defined objects of the
  9. class OneDbf.
  10.  
  11. Common use:
  12. ~~~~~~~~~~~
  13. It is evident from examples Demo1.prg and Demo2.prg, i.e. creation of an
  14. object from class database, defining of database structure, opening of
  15. database, reindex, ...
  16.  
  17. Source code of Dbf class is in C_Dbf.prg
  18.  
  19. !seealso: c_onedbf.ngo:OneDbf c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  20.  
  21. !short:~~~~~~~~~~~~~~~~~~~~
  22. !short:create class Dbf
  23. !short:  export:
  24. !short:  var lNew         //false
  25. ^BDbf:New^N: public: logical
  26.   It recieves the value only after the creation of databases by Create()
  27.   method and serves for distinguish if the password is required when the
  28.   program starts or not. When databases are created automaticaly there is
  29.   no need to require the password the databases are empty.
  30.  
  31. !short:  var Data         //{}
  32. ^BDbf:Data^N: read-only: array
  33.  This field stores objects of class OneDbf, related to this object.
  34.  
  35. !short:  method New=DbfNew                 //o:New() --> self
  36. ^BDbf:New()^N: public: return self
  37.   Object is filled with default values.
  38.  
  39. !short:  method Password=DbfPassword       //o:Password() --> true
  40. ^BMenu:Password()^N: public: return true
  41.   The instvar variable New of an object of Dbf class is checked for
  42.   welcoming the supervisor or for require of user name and password.
  43.   This method assigns the visibility of menu according to the user privilege
  44.   level. Privilege levels of users are assigned by supervisor.
  45.  
  46. !short:  method Init=DbfInit               //o:Init() --> true
  47. ^BDbf:Init()^N: public: return true
  48.   Object is initialised.
  49.  
  50. !short:  method Create=DbfCreate           //o:Create() --> true
  51. ^BDbf:Create()^N: public: return true
  52.   All databases and index files are created and opened. The system database
  53.   files ^USystem1.dbf^N, ^USystem2.dbf^N and ^USystem3.dbf^N are created
  54.   and used for internal library functions.
  55.   The description is in Basic knowledges ØØ Database files.
  56.  
  57. !short:  method Open=DbfOpen               //o:Open() --> true
  58. ^BDbf:Open()^N: public: return true
  59.   All required database files and their respective index files are opened.
  60.   If a required database file don't exist, then will be created!
  61.   The opening is done for network environment.
  62.  
  63. !short:  method ReIndex=DbfReIndex         //o:ReIndex(lContinue) --> true/false
  64. ^BDbf:ReIndex(lContinue)^N: public: return true/false
  65.   All database files are reindexed, if succesfully then returns true
  66.   otherwise false.
  67.  
  68. !short:  method Pack=DbfPack               //o:Pack(lContinue) --> true/false
  69. ^BDbf:Pack(lContinue)^N: public: return true/false
  70.   All database files are packed, if succesfully then returns true
  71.   otherwise false.
  72.  
  73. !short:  method Zap=DbfZap                 //o:Zap(lContinue) --> true/false
  74. ^BDbf:Zap(lContinue)^N: public: return true/false
  75.   All database files are zapped, if succesfully then returns true
  76.   otherwise false.
  77.  
  78. !short:  method AddDbf=DbfAddDbf           //o:AddDbf(cFile) --> true
  79. ^BDbf:AddDbf(cFile)^N: public: return true
  80.   New database is added to internal database list. New object of OneDbf class
  81.   is created and added to instvar variable Data.
  82.  
  83.   Parameter description:
  84.   ~~~~~~~~~~~~~~~~~~~~~~~
  85.   ^UcFile^N: character: no default
  86.    It is database file name, stored to instvar variable OneDbf:File, its name
  87.    without the path is stored as alias to instvar variable OneDbf:Name.
  88.  
  89. !short:  method AddField=DbfAddField       //o:AddField(cName,cType,nLen,nDec) --> true
  90. ^BDbf:AddField(cName,cType,nLen,nDec)^N: public: return true
  91.   The last created object OneDbf is appended with next field.
  92.  
  93.   Parameter desription:
  94.   ~~~~~~~~~~~~~~~~~~~~~~~
  95.   ^UcName^N: character: no default
  96.    new database field name
  97.  
  98.   ^UcType^N: character: no default
  99.    Database field type, could be "C","M","N","D" or "L
  100.  
  101.  
  102.   ^UnLen^N: numeric: default is 10,8 or 1 (after field type)
  103.    Database field size.
  104.  
  105.   ^UnDec^N: numeric: default is 0
  106.    It is number of decimal digits for "N" type, or adding the width
  107.    of type "C" in multiples of 256. (see the clipper manuals)
  108.  
  109. !short:  method AddNtx=DbfAddNtx           //o:AddNtx(cName,cFile,cKey,lUnique) --> true
  110. ^BDbf:AddNtx(cName,cFile,cKey,lUnique)^N: public: return true
  111.   Last new created object OneDbf is appended with definition of next index
  112.   file.
  113.  
  114.   Parameter description:
  115.   ~~~~~~~~~~~~~~~~~~~~~~
  116.   ^UcName^N: character: no default
  117.    Menu item name for selection of this index file (SET ORDER).
  118.  
  119.   ^UcFile^N: character: no default
  120.    Index file name.
  121.  
  122.   ^UcKey^N: character: no default
  123.    Key expresion for index file.
  124.  
  125.   ^UlUnique^N: logical: default is false
  126.    Controls the UNIQUE index keys.
  127.  
  128. !short:  method AddRelation=DbfAddRelation //o:AddRelation(xKey,cAlias,nOrder) --> true
  129. ^BDbf:AddRelation(xKey,cAlias,nOrder)^N: public: return true
  130.   Last created object OneDbf is appended with next relation definition.
  131.  
  132.   Parameter description:
  133.   ~~~~~~~~~~~~~~~~~~~~~~
  134.   ^UcKey^N: character: no default
  135.    Key expresion as text string, for making relation is this evaluated
  136.    for SEEK command.
  137.  
  138.   ^UcAlias^N: character: no default
  139.    Work area selection for SEEK command.
  140.  
  141.   ^UnOrder^N: numeric: no default
  142.    Order of active index in "cAlias" workarea.
  143.  
  144. !short:  method Picture=DbfPicture         //o:Picture(cPict) --> true
  145. ^BDbf:Picture(cPict)^N: public: return true
  146.   To last created object of class OneDbf is stored the information about
  147.   the display mask of last defined database field.
  148.  
  149.   Parameter description:
  150.   ~~~~~~~~~~~~~~~~~~~~~~
  151.   ^UcPict^N: character: no default
  152.    Display mask.
  153.  
  154. !short:  method Range=DbfRange             //o:Range(nLo,nHi) --> true
  155. ^BDbf:Range(nLo,nHi)^N: public: return true
  156.   To last created object of class OneDbf is stored the code block Valid
  157.   to check the validity of database field value range.
  158.  
  159.   Parameter description:
  160.   ~~~~~~~~~~~~~~~~~~~~~~~
  161.   ^UnLo^N: numeric: no default
  162.    Low field value range.
  163.  
  164.   ^UnHi^N: numeric: no default
  165.    High (upper) field value range.
  166.  
  167. !short:  method When=DbfWhen               //o:When(bWhen) --> true
  168. ^BDbf:When(bWhen)^N: public: return true
  169.   To last created object of OneDbf class is for last defined database field
  170.   stored code block When. This code block is processed for entering this
  171.   database field. If returning false the field editation is skipped.
  172.  
  173. !short:  method Valid=DbfValid_            //o:Valid(bValid) --> true
  174. ^BDbf:Valid(bValid)^N: public: return true
  175.   To last created object of OneDbf class is for last defined database field
  176.   stored code block Valid. This code block is processed after finishig of
  177.   editation of this database field. If returning false the field editation
  178.   can't be finished (incorrect value entered). The code block "bValid", when
  179.   evaluated, will be passed this parameters:
  180.    - currently edited (clipper) Get object.
  181.    - logical value CanEdit (true if editting allowed)
  182.    - old edited value, (it is saved into temporary variable before editting
  183.      of the Get object) 
  184.  
  185. !short:  method ChValid=DbfChValid         //o:ChValid(bValid) --> true
  186. ^BDbf:ChValid(bValid)^N: public: return true
  187.   To last created object of OneDbf class is for last defined database field
  188.   stored code block Valid . This code block is processed after finishig of
  189.   editation of this database field only when the database filed was changed.
  190.   If returning false the field editation  can't be finished. (incorrect
  191.   value entered). The code block "bValid", when
  192.   evaluated, will be passed this parameters:
  193.    - currently edited (clipper) Get object.
  194.    - logical value CanEdit (true if editting allowed)
  195.    - old edited value, (it is saved into temporary variable before editting
  196.      of the Get object)
  197.  
  198. !short:  method Save=DbfSave               //o:Save(cPath) --> true/false
  199. ^BDbf:Save(cPath)^N: public: return true/false
  200.   With help of external utility ARCHIV.exe stores all data files of this
  201.   program to ARCHIV.000 file to desired device. If the desired device
  202.   according of the cPath is the floppy drive and the data files overflowed
  203.   the floppy disk, the utility asks for new disk and the archiving process
  204.   continues with the file name ARCHIV.001 and so on. Data files are all
  205.   files of the current directory with extensions *.dbf, *.dbt, *.ntx.
  206.   If the archiving succeeded it returns true otherwise false.
  207.  
  208. !short:  method Load=DbfLoad               //o:Load(cPath) --> do_nothing
  209. ^BDbf:Load(cPath)^N: public: return false/???
  210.   It is the complement of Dbf:Save() method. It enables to restore all data
  211.   files of the program, stored by Dbf:Save(). If it is not possible to
  212.   restore all files the false is returned. If the restoring succeeded
  213.   it is not possible to continue in program immediately (due to indexes,
  214.   filters and reports) but the program is stopped and the user is asked
  215.   for the restart. After restarting the program the files are reindexed
  216.   and the recovery is succesfully finished.
  217.  
  218. !short:  method Done=DbfDone               //o:Done() --> true
  219. ^BDbf:Done()^N: public: return true
  220.   User is logged out from library file system, all files are closed
  221.   and returns true.
  222.  
  223. !short:  endclass
  224.  
  225.